package com.juttec.freshbird.pet.base.baseimpl;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.juttec.freshbird.pet.MainActivity;
import com.juttec.freshbird.pet.R;
import com.juttec.freshbird.pet.base.BasePager;
import com.juttec.freshbird.pet.fragment.LeftFragment;
import com.juttec.freshbird.pet.utils.FragmentIndicator;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * Created by Administrator on 2015/10/21.
 */
public class LuntanPager extends BasePager {
    //ViewUtils提供的注入方式初始化控件
    //通过注入的方式初始化论坛界面的“宠物论坛textview”
    @ViewInject(R.id.luntan_chongwu)
    private TextView tvChongwu;
    //通过注入的方式初始化论坛界面的“地区论坛textview”
    @ViewInject(R.id.luntan_diqu)
    private TextView tvDiqu;
    //通过注入的方式初始化论坛界面的“主题论坛textview”
    @ViewInject(R.id.luntan_topic)
    private TextView tvTopic;
    private final LeftFragment leftMenuFragment;

    public LuntanPager(Activity activity) {
        super(activity);
        //构造方法中获得侧拉框事务fragment
        MainActivity mainUi = (MainActivity) mActivity;
        leftMenuFragment = mainUi.getLeftMenuFragment();
    }

    @Override
    public View initViews() {
        View view = View.inflate(mActivity, R.layout.page_luntan, null);
        ViewUtils.inject(this,view);
        return view;
    }

    @Override
    public void initData() {
        //设置无法拉出侧边栏
        setSlidingMenuNone();
        tvChongwu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //调用父类方法：设置论坛界面右边栏打开方式
                setSlidingMenuRightEnable();
                leftMenuFragment.setChongwuAdapter();
                //调用父类方法：切换侧边栏
                toggleSlidingMenu();

            }
        });
        tvDiqu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //调用父类方法：设置论坛界面右边栏打开方式
                setSlidingMenuRightEnable();
                leftMenuFragment.setDiquAdapter();
                //调用父类方法：切换侧边栏
                toggleSlidingMenu();
            }
        });
        tvTopic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //调用父类方法：设置论坛界面右边栏打开方式
                setSlidingMenuRightEnable();
                leftMenuFragment.setTopicAdapter();
                //调用父类方法：切换侧边栏
                toggleSlidingMenu();
            }
        });
    }
}
